<!DOCTYPE html><html><head><meta charset="utf-8"><style>body {
  max-width: 980px;
  border: 1px solid #ddd;
  outline: 1300px solid #fff;
  margin: 16px auto;
}

body .markdown-body
{
  padding: 45px;
}

@font-face {
  font-family: fontawesome-mini;
  src: url(data:font/woff;charset=utf-8;base64,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) format('woff');
}

@font-face {
  font-family: octicons-anchor;
  src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK69ExKslx7Xa+vPRVS43G98vG1DnkDMIBUgFN0MDXflU8tbaZOUkXUH0+U27RoRpOIyCKjbMCVejwypzJJG4jIwb43rfl6wbwanocrJm9XFYfskuVC5K/TPyczNU7b84CXcbxks1Un6H6tLH9vf2LRnn8Ax7A5WQAAAHicY2BkYGAA4teL1+yI57f5ysDNwgAC529f0kOmWRiYVgEpDgYmEA8AUzEKsQAAAHicY2BkYGB2+O/AEMPCAAJAkpEBFbAAADgKAe0EAAAiAAAAAAQAAAAEAAAAAAAAKgAqACoAiAAAeJxjYGRgYGBhsGFgYgABEMkFhAwM/xn0QAIAD6YBhwB4nI1Ty07cMBS9QwKlQapQW3VXySvEqDCZGbGaHULiIQ1FKgjWMxknMfLEke2A+IJu+wntrt/QbVf9gG75jK577Lg8K1qQPCfnnnt8fX1NRC/pmjrk/zprC+8D7tBy9DHgBXoWfQ44Av8t4Bj4Z8CLtBL9CniJluPXASf0Lm4CXqFX8Q84dOLnMB17N4c7tBo1AS/Qi+hTwBH4rwHHwN8DXqQ30XXAS7QaLwSc0Gn8NuAVWou/gFmnjLrEaEh9GmDdDGgL3B4JsrRPDU2hTOiMSuJUIdKQQayiAth69r6akSSFqIJuA19TrzCIaY8sIoxyrNIrL//pw7A2iMygkX5vDj+G+kuoLdX4GlGK/8Lnlz6/h9MpmoO9rafrz7ILXEHHaAx95s9lsI7AHNMBWEZHULnfAXwG9/ZqdzLI08iuwRloXE8kfhXYAvE23+23DU3t626rbs8/8adv+9DWknsHp3E17oCf+Z48rvEQNZ78paYM38qfk3v/u3l3u3GXN2Dmvmvpf1Srwk3pB/VSsp512bA/GG5i2WJ7wu430yQ5K3nFGiOqgtmSB5pJVSizwaacmUZzZhXLlZTq8qGGFY2YcSkqbth6aW1tRmlaCFs2016m5qn36SbJrqosG4uMV4aP2PHBmB3tjtmgN2izkGQyLWprekbIntJFing32a5rKWCN/SdSoga45EJykyQ7asZvHQ8PTm6cslIpwyeyjbVltNikc2HTR7YKh9LBl9DADC0U/jLcBZDKrMhUBfQBvXRzLtFtjU9eNHKin0x5InTqb8lNpfKv1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff');
}

.markdown-body {
  font-family: sans-serif;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  color: #333333;
  overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-wrap: break-word;
}

.markdown-body a {
  background: transparent;
}

.markdown-body a:active,
.markdown-body a:hover {
  outline: 0;
}

.markdown-body b,
.markdown-body strong {
  font-weight: bold;
}

.markdown-body mark {
  background: #ff0;
  color: #000;
  font-style: italic;
  font-weight: bold;
}

.markdown-body sub,
.markdown-body sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
.markdown-body sup {
  top: -0.5em;
}
.markdown-body sub {
  bottom: -0.25em;
}

.markdown-body h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

.markdown-body img {
  border: 0;
}

.markdown-body hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  height: 0;
}

.markdown-body pre {
  overflow: auto;
}

.markdown-body code,
.markdown-body kbd,
.markdown-body pre,
.markdown-body samp {
  font-family: monospace, monospace;
  font-size: 1em;
}

.markdown-body input {
  color: inherit;
  font: inherit;
  margin: 0;
}

.markdown-body html input[disabled] {
  cursor: default;
}

.markdown-body input {
  line-height: normal;
}

.markdown-body input[type="checkbox"] {
  box-sizing: border-box;
  padding: 0;
}

.markdown-body table {
  border-collapse: collapse;
  border-spacing: 0;
}

.markdown-body td,
.markdown-body th {
  padding: 0;
}

.markdown-body .codehilitetable {
  border: 0;
  border-spacing: 0;
}

.markdown-body .codehilitetable tr {
  border: 0;
}

.markdown-body .codehilitetable pre,
.markdown-body .codehilitetable div.codehilite {
  margin: 0;
}

.markdown-body .linenos,
.markdown-body .code,
.markdown-body .codehilitetable td {
  border: 0;
  padding: 0;
}

.markdown-body td:not(.linenos) .linenodiv {
  padding: 0 !important;
}

.markdown-body .code {
  width: 100%;
}

.markdown-body .linenos div pre,
.markdown-body .linenodiv pre,
.markdown-body .linenodiv {
  border: 0;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
  -webkit-border-top-left-radius: 3px;
  -webkit-border-bottom-left-radius: 3px;
  -moz-border-radius-topleft: 3px;
  -moz-border-radius-bottomleft: 3px;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.markdown-body .code div pre,
.markdown-body .code div {
  border: 0;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
  -webkit-border-top-right-radius: 3px;
  -webkit-border-bottom-right-radius: 3px;
  -moz-border-radius-topright: 3px;
  -moz-border-radius-bottomright: 3px;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

.markdown-body * {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.markdown-body input {
  font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.4;
}

.markdown-body a {
  color: #4183c4;
  text-decoration: none;
}

.markdown-body a:hover,
.markdown-body a:focus,
.markdown-body a:active {
  text-decoration: underline;
}

.markdown-body hr {
  height: 0;
  margin: 15px 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #ddd;
}

.markdown-body hr:before,
.markdown-body hr:after {
  display: table;
  content: " ";
}

.markdown-body hr:after {
  clear: both;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 15px;
  margin-bottom: 15px;
  line-height: 1.1;
}

.markdown-body h1 {
  font-size: 30px;
}

.markdown-body h2 {
  font-size: 21px;
}

.markdown-body h3 {
  font-size: 16px;
}

.markdown-body h4 {
  font-size: 14px;
}

.markdown-body h5 {
  font-size: 12px;
}

.markdown-body h6 {
  font-size: 11px;
}

.markdown-body blockquote {
  margin: 0;
}

.markdown-body ul,
.markdown-body ol {
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body ol ol,
.markdown-body ul ol {
  list-style-type: lower-roman;
}

.markdown-body ul ul ol,
.markdown-body ul ol ol,
.markdown-body ol ul ol,
.markdown-body ol ol ol {
  list-style-type: lower-alpha;
}

.markdown-body dd {
  margin-left: 0;
}

.markdown-body code,
.markdown-body pre,
.markdown-body samp {
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 12px;
}

.markdown-body pre {
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body kbd {
  background-color: #e7e7e7;
  background-image: -moz-linear-gradient(#fefefe, #e7e7e7);
  background-image: -webkit-linear-gradient(#fefefe, #e7e7e7);
  background-image: linear-gradient(#fefefe, #e7e7e7);
  background-repeat: repeat-x;
  border-radius: 2px;
  border: 1px solid #cfcfcf;
  color: #000;
  padding: 3px 5px;
  line-height: 10px;
  font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  display: inline-block;
}

.markdown-body>*:first-child {
  margin-top: 0 !important;
}

.markdown-body>*:last-child {
  margin-bottom: 0 !important;
}

.markdown-body .headeranchor-link {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: block;
  padding-right: 6px;
  padding-left: 30px;
  margin-left: -30px;
}

.markdown-body .headeranchor-link:focus {
  outline: none;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  position: relative;
  margin-top: 1em;
  margin-bottom: 16px;
  font-weight: bold;
  line-height: 1.4;
}

.markdown-body h1 .headeranchor,
.markdown-body h2 .headeranchor,
.markdown-body h3 .headeranchor,
.markdown-body h4 .headeranchor,
.markdown-body h5 .headeranchor,
.markdown-body h6 .headeranchor {
  display: none;
  color: #000;
  vertical-align: middle;
}

.markdown-body h1:hover .headeranchor-link,
.markdown-body h2:hover .headeranchor-link,
.markdown-body h3:hover .headeranchor-link,
.markdown-body h4:hover .headeranchor-link,
.markdown-body h5:hover .headeranchor-link,
.markdown-body h6:hover .headeranchor-link {
  height: 1em;
  padding-left: 8px;
  margin-left: -30px;
  line-height: 1;
  text-decoration: none;
}

.markdown-body h1:hover .headeranchor-link .headeranchor,
.markdown-body h2:hover .headeranchor-link .headeranchor,
.markdown-body h3:hover .headeranchor-link .headeranchor,
.markdown-body h4:hover .headeranchor-link .headeranchor,
.markdown-body h5:hover .headeranchor-link .headeranchor,
.markdown-body h6:hover .headeranchor-link .headeranchor {
  display: inline-block;
}

.markdown-body h1 {
  padding-bottom: 0.3em;
  font-size: 2.25em;
  line-height: 1.2;
  border-bottom: 1px solid #eee;
}

.markdown-body h2 {
  padding-bottom: 0.3em;
  font-size: 1.75em;
  line-height: 1.225;
  border-bottom: 1px solid #eee;
}

.markdown-body h3 {
  font-size: 1.5em;
  line-height: 1.43;
}

.markdown-body h4 {
  font-size: 1.25em;
}

.markdown-body h5 {
  font-size: 1em;
}

.markdown-body h6 {
  font-size: 1em;
  color: #777;
}

.markdown-body p,
.markdown-body blockquote,
.markdown-body ul,
.markdown-body ol,
.markdown-body dl,
.markdown-body table,
.markdown-body pre,
.markdown-body .admonition {
  margin-top: 0;
  margin-bottom: 16px;
}

.markdown-body hr {
  height: 4px;
  padding: 0;
  margin: 16px 0;
  background-color: #e7e7e7;
  border: 0 none;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 2em;
}

.markdown-body ul ul,
.markdown-body ul ol,
.markdown-body ol ol,
.markdown-body ol ul {
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body li>p {
  margin-top: 16px;
}

.markdown-body dl {
  padding: 0;
}

.markdown-body dl dt {
  padding: 0;
  margin-top: 16px;
  font-size: 1em;
  font-style: italic;
  font-weight: bold;
}

.markdown-body dl dd {
  padding: 0 16px;
  margin-bottom: 16px;
}

.markdown-body blockquote {
  padding: 0 15px;
  color: #777;
  border-left: 4px solid #ddd;
}

.markdown-body blockquote>:first-child {
  margin-top: 0;
}

.markdown-body blockquote>:last-child {
  margin-bottom: 0;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow: auto;
  word-break: normal;
  word-break: keep-all;
}

.markdown-body table th {
  font-weight: bold;
}

.markdown-body table th,
.markdown-body table td {
  padding: 6px 13px;
  border: 1px solid #ddd;
}

.markdown-body table tr {
  background-color: #fff;
  border-top: 1px solid #ccc;
}

.markdown-body table tr:nth-child(2n) {
  background-color: #f8f8f8;
}

.markdown-body img {
  max-width: 100%;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.markdown-body code,
.markdown-body samp {
  padding: 0;
  padding-top: 0.2em;
  padding-bottom: 0.2em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(0,0,0,0.04);
  border-radius: 3px;
}

.markdown-body code:before,
.markdown-body code:after {
  letter-spacing: -0.2em;
  content: "\00a0";
}

.markdown-body pre>code {
  padding: 0;
  margin: 0;
  font-size: 100%;
  word-break: normal;
  white-space: pre;
  background: transparent;
  border: 0;
}

.markdown-body .codehilite {
  margin-bottom: 16px;
}

.markdown-body .codehilite pre,
.markdown-body pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #f7f7f7;
  border-radius: 3px;
}

.markdown-body .codehilite pre {
  margin-bottom: 0;
  word-break: normal;
}

.markdown-body pre {
  word-wrap: normal;
}

.markdown-body pre code {
  display: inline;
  max-width: initial;
  padding: 0;
  margin: 0;
  overflow: initial;
  line-height: inherit;
  word-wrap: normal;
  background-color: transparent;
  border: 0;
}

.markdown-body pre code:before,
.markdown-body pre code:after {
  content: normal;
}

/* Admonition */
.markdown-body .admonition {
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  position: relative;
  border-radius: 3px;
  border: 1px solid #e0e0e0;
  border-left: 6px solid #333;
  padding: 10px 10px 10px 30px;
}

.markdown-body .admonition table {
  color: #333;
}

.markdown-body .admonition p {
  padding: 0;
}

.markdown-body .admonition-title {
  font-weight: bold;
  margin: 0;
}

.markdown-body .admonition>.admonition-title {
  color: #333;
}

.markdown-body .attention>.admonition-title {
  color: #a6d796;
}

.markdown-body .caution>.admonition-title {
  color: #d7a796;
}

.markdown-body .hint>.admonition-title {
  color: #96c6d7;
}

.markdown-body .danger>.admonition-title {
  color: #c25f77;
}

.markdown-body .question>.admonition-title {
  color: #96a6d7;
}

.markdown-body .note>.admonition-title {
  color: #d7c896;
}

.markdown-body .admonition:before,
.markdown-body .attention:before,
.markdown-body .caution:before,
.markdown-body .hint:before,
.markdown-body .danger:before,
.markdown-body .question:before,
.markdown-body .note:before {
  font: normal normal 16px fontawesome-mini;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  line-height: 1.5;
  color: #333;
  position: absolute;
  left: 0;
  top: 0;
  padding-top: 10px;
  padding-left: 10px;
}

.markdown-body .admonition:before {
  content: "\f056\00a0";
  color: 333;
}

.markdown-body .attention:before {
  content: "\f058\00a0";
  color: #a6d796;
}

.markdown-body .caution:before {
  content: "\f06a\00a0";
  color: #d7a796;
}

.markdown-body .hint:before {
  content: "\f05a\00a0";
  color: #96c6d7;
}

.markdown-body .danger:before {
  content: "\f057\00a0";
  color: #c25f77;
}

.markdown-body .question:before {
  content: "\f059\00a0";
  color: #96a6d7;
}

.markdown-body .note:before {
  content: "\f040\00a0";
  color: #d7c896;
}

.markdown-body .admonition::after {
  content: normal;
}

.markdown-body .attention {
  border-left: 6px solid #a6d796;
}

.markdown-body .caution {
  border-left: 6px solid #d7a796;
}

.markdown-body .hint {
  border-left: 6px solid #96c6d7;
}

.markdown-body .danger {
  border-left: 6px solid #c25f77;
}

.markdown-body .question {
  border-left: 6px solid #96a6d7;
}

.markdown-body .note {
  border-left: 6px solid #d7c896;
}

.markdown-body .admonition>*:first-child {
  margin-top: 0 !important;
}

.markdown-body .admonition>*:last-child {
  margin-bottom: 0 !important;
}

/* progress bar*/
.markdown-body .progress {
  display: block;
  width: 300px;
  margin: 10px 0;
  height: 24px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  background-color: #ededed;
  position: relative;
  box-shadow: inset -1px 1px 3px rgba(0, 0, 0, .1);
}

.markdown-body .progress-label {
  position: absolute;
  text-align: center;
  font-weight: bold;
  width: 100%; margin: 0;
  line-height: 24px;
  color: #333;
  text-shadow: 1px 1px 0 #fefefe, -1px -1px 0 #fefefe, -1px 1px 0 #fefefe, 1px -1px 0 #fefefe, 0 1px 0 #fefefe, 0 -1px 0 #fefefe, 1px 0 0 #fefefe, -1px 0 0 #fefefe, 1px 1px 2px #000;
  -webkit-font-smoothing: antialiased !important;
  white-space: nowrap;
  overflow: hidden;
}

.markdown-body .progress-bar {
  height: 24px;
  float: left;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  background-color: #96c6d7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .1);
  background-size: 30px 30px;
  background-image: -webkit-linear-gradient(
    135deg, rgba(255, 255, 255, .4) 27%,
    transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%,
    transparent 77%, transparent
  );
  background-image: -moz-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: -ms-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: -o-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
}

.markdown-body .progress-100plus .progress-bar {
  background-color: #a6d796;
}

.markdown-body .progress-80plus .progress-bar {
  background-color: #c6d796;
}

.markdown-body .progress-60plus .progress-bar {
  background-color: #d7c896;
}

.markdown-body .progress-40plus .progress-bar {
  background-color: #d7a796;
}

.markdown-body .progress-20plus .progress-bar {
  background-color: #d796a6;
}

.markdown-body .progress-0plus .progress-bar {
  background-color: #c25f77;
}

.markdown-body .candystripe-animate .progress-bar{
  -webkit-animation: animate-stripes 3s linear infinite;
  -moz-animation: animate-stripes 3s linear infinite;
  animation: animate-stripes 3s linear infinite;
}

@-webkit-keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

@-moz-keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

@keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

.markdown-body .gloss .progress-bar {
  box-shadow:
    inset 0 4px 12px rgba(255, 255, 255, .7),
    inset 0 -12px 0 rgba(0, 0, 0, .05);
}

/* Multimarkdown Critic Blocks */
.markdown-body .critic_mark {
  background: #ff0;
}

.markdown-body .critic_delete {
  color: #c82829;
  text-decoration: line-through;
}

.markdown-body .critic_insert {
  color: #718c00 ;
  text-decoration: underline;
}

.markdown-body .critic_comment {
  color: #8e908c;
  font-style: italic;
}

.markdown-body .headeranchor {
  font: normal normal 16px octicons-anchor;
  line-height: 1;
  display: inline-block;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.headeranchor:before {
  content: '\f05c';
}

.markdown-body .task-list-item {
  list-style-type: none;
}

.markdown-body .task-list-item+.task-list-item {
  margin-top: 3px;
}

.markdown-body .task-list-item input {
  margin: 0 4px 0.25em -20px;
  vertical-align: middle;
}

/* Media */
@media only screen and (min-width: 480px) {
  .markdown-body {
    font-size:14px;
  }
}

@media only screen and (min-width: 768px) {
  .markdown-body {
    font-size:16px;
  }
}

@media print {
  .markdown-body * {
    background: transparent !important;
    color: black !important;
    filter:none !important;
    -ms-filter: none !important;
  }

  .markdown-body {
    font-size:12pt;
    max-width:100%;
    outline:none;
    border: 0;
  }

  .markdown-body a,
  .markdown-body a:visited {
    text-decoration: underline;
  }

  .markdown-body .headeranchor-link {
    display: none;
  }

  .markdown-body a[href]:after {
    content: " (" attr(href) ")";
  }

  .markdown-body abbr[title]:after {
    content: " (" attr(title) ")";
  }

  .markdown-body .ir a:after,
  .markdown-body a[href^="javascript:"]:after,
  .markdown-body a[href^="#"]:after {
    content: "";
  }

  .markdown-body pre {
    white-space: pre;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .markdown-body pre,
  .markdown-body blockquote {
    border: 1px solid #999;
    padding-right: 1em;
    page-break-inside: avoid;
  }

  .markdown-body .progress,
  .markdown-body .progress-bar {
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
  }

  .markdown-body .progress {
    border: 1px solid #ddd;
  }

  .markdown-body .progress-bar {
    height: 22px;
    border-right: 1px solid #ddd;
  }

  .markdown-body tr,
  .markdown-body img {
    page-break-inside: avoid;
  }

  .markdown-body img {
    max-width: 100% !important;
  }

  .markdown-body p,
  .markdown-body h2,
  .markdown-body h3 {
    orphans: 3;
    widows: 3;
  }

  .markdown-body h2,
  .markdown-body h3 {
    page-break-after: avoid;
  }
}
</style><title>ES6编程规范</title></head><body><article class="markdown-body"><h1 id="ecmascript-6-style-guide"><a name="user-content-ecmascript-6-style-guide" href="#ecmascript-6-style-guide" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>ECMAScript 6 Style Guide</h1>
<p><strong>用更合理的方式写 JavaScript</strong></p>
<p>参考自 <a href="https://github.com/airbnb/javascript">Airbnb JavaScript Style Guide</a> 。</p>
<p><a name="table-of-contents"></a></p>
<h2 id="_1"><a name="user-content-_1" href="#_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>目录</h2>
<ol>
<li><a href="#types">类型</a></li>
<li><a href="#references">引用</a></li>
<li><a href="#objects">对象</a></li>
<li><a href="#arrays">数组</a></li>
<li><a href="#destructuring">解构</a></li>
<li><a href="#strings">字符串</a></li>
<li><a href="#functions">函数</a></li>
<li><a href="#arrow-functions">箭头函数</a></li>
<li><a href="#constructors">构造函数</a></li>
<li><a href="#modules">模块</a></li>
<li><a href="#iterators-and-generators">Iterators &amp; Generators </a></li>
<li><a href="#properties">属性</a></li>
<li><a href="#variables">变量</a></li>
<li><a href="#hoisting">提升</a></li>
<li><a href="#comparison-operators--equality">比较运算符 &amp; 等号</a></li>
<li><a href="#blocks">代码块</a></li>
<li><a href="#comments">注释</a></li>
<li><a href="#whitespace">空白</a></li>
<li><a href="#commas">逗号</a></li>
<li><a href="#semicolons">分号</a></li>
<li><a href="#type-casting--coercion">类型转换</a></li>
<li><a href="#naming-conventions">命名规则</a></li>
<li><a href="#accessors">存取器</a></li>
<li><a href="#events">事件</a></li>
<li><a href="#jquery">jQuery</a></li>
<li><a href="#ecmascript-5-compatibility">ECMAScript 5 兼容性</a></li>
<li><a href="#ecmascript-6-styles">ECMAScript 6 编码规范</a></li>
<li><a href="#testing">测试</a></li>
<li><a href="#performance">性能</a></li>
<li><a href="#resources">资源</a></li>
<li><a href="#in-the-wild">使用人群</a></li>
<li><a href="#translation">翻译</a></li>
<li><a href="#the-javascript-style-guide-guide">JavaScript 编码规范说明</a></li>
<li><a href="#chat-with-us-about-javascript">一起来讨论 JavaScript</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#license">License</a></li>
</ol>
<p><a name="types"></a></p>
<h2 id="_2"><a name="user-content-_2" href="#_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>类型</h2>
<ul>
<li>
<p><a href="#1.1">1.1</a> <a name='1.1'></a> <strong>基本类型</strong>: 直接存取基本类型。</p>
<ul>
<li><code>字符串</code></li>
<li><code>数值</code></li>
<li><code>布尔类型</code></li>
<li><code>null</code></li>
<li><code>undefined</code></li>
</ul>
<p><pre><code class="javascript">const foo = 1;
let bar = foo;

bar = 9;

console.log(foo, bar); // =&gt; 1, 9
</code></pre><br />
  - <a href="#1.2">1.2</a> <a name='1.2'></a> <strong>复制类型</strong>: 通过引用的方式存取复杂类型。</p>
<ul>
<li><code>对象</code></li>
<li><code>数组</code></li>
<li><code>函数</code></li>
</ul>
<pre><code class="javascript">const foo = [1, 2];
const bar = foo;

bar[0] = 9;

console.log(foo[0], bar[0]); // =&gt; 9, 9
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="references"></a></p>
<h2 id="_3"><a name="user-content-_3" href="#_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>引用</h2>
<ul>
<li><a href="#2.1">2.1</a> <a name='2.1'></a> 对所有的引用使用 <code>const</code> ；不要使用 <code>var</code>。</li>
</ul>
<blockquote>
<p>为什么？这能确保你无法对引用重新赋值，也不会导致出现 bug 或难以理解。</p>
</blockquote>
<pre><code>```javascript
// bad
var a = 1;
var b = 2;

// good
const a = 1;
const b = 2;
```
</code></pre>
<ul>
<li><a href="#2.2">2.2</a> <a name='2.2'></a> 如果你一定需要可变动的引用，使用 <code>let</code> 代替 <code>var</code>。</li>
</ul>
<blockquote>
<p>为什么？因为  <code>let</code> 是块级作用域，而 <code>var</code> 是函数作用域。</p>
</blockquote>
<pre><code>```javascript
// bad
var count = 1;
if (true) {
  count += 1;
}

// good, use the let.
let count = 1;
if (true) {
  count += 1;
}
```
</code></pre>
<ul>
<li><a href="#2.3">2.3</a> <a name='2.3'></a> 注意 <code>let</code> 和 <code>const</code> 都是块级作用域。</li>
<li><strong>在一个作用域内不能重复声明</strong> </li>
<li>
<p><code>const</code>在声明的时候必须初始化 <code>let</code>在声明的时候可以不用初始化</p>
<pre><code class="javascript">// const 和 let 只存在于它们被定义的区块内。
{
  let a = 1;
  const b = 1;
  // error
  let a = 2;
  // error
  const b ;
  const b = 3;
}
console.log(a); // ReferenceError
console.log(b); // ReferenceError
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="objects"></a></p>
<h2 id="_4"><a name="user-content-_4" href="#_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>对象</h2>
<ul>
<li>
<p><a href="#3.1">3.1</a> <a name='3.1'></a> 使用字面值创建对象。</p>
<pre><code class="javascript">// bad
const item = new Object();

// good
const item = {};
</code></pre>

</li>
<li>
<p><a href="#3.2">3.2</a> <a name='3.2'></a> 如果你的代码在浏览器环境下执行，别使用 <a href="http://es5.github.io/#x7.6.1">保留字</a> 作为键值。这样的话在 IE8 不会运行。 <a href="https://github.com/airbnb/javascript/issues/61">更多信息</a>。 但在 ES6 模块和服务器端中使用没有问题。</p>
<pre><code class="javascript">// bad
const superman = {
  default: { clark: 'kent' },
  private: true,
};

// good
const superman = {
  defaults: { clark: 'kent' },
  hidden: true,
};
</code></pre>

</li>
<li>
<p><a href="#3.3">3.3</a> <a name='3.3'></a> 使用同义词替换需要使用的保留字。</p>
<pre><code class="javascript">// bad
const superman = {
  class: 'alien',
};

// bad
const superman = {
  klass: 'alien',
};

// good
const superman = {
  type: 'alien',
};
</code></pre>

</li>
</ul>
<p><a name="es6-computed-properties"></a><br />
  - <a href="#3.4">3.4</a> <a name='3.4'></a> 创建有动态属性名的对象时，使用可被计算的属性名称。</p>
<blockquote>
<p>为什么？因为这样可以让你在一个地方定义所有的对象属性。</p>
</blockquote>
<pre><code>```javascript
function getKey(k) {
  return `a key named ${k}`;
}

// bad
const obj = {
  id: 5,
  name: 'San Francisco',
};
obj[getKey('enabled')] = true;

// good
const obj = {
  id: 5,
  name: 'San Francisco',
  [getKey('enabled')]: true,
};
```
</code></pre>
<p><a name="es6-object-shorthand"></a><br />
  - <a href="#3.5">3.5</a> <a name='3.5'></a> 使用对象方法的简写。</p>
<pre><code>```javascript
// bad
const atom = {
  value: 1,

  addValue: function (value) {
    return atom.value + value;
  },
};

// good
const atom = {
  value: 1,

  addValue(value) {
    return atom.value + value;
  },
};
```
</code></pre>
<p><a name="es6-object-concise"></a><br />
  - <a href="#3.6">3.6</a> <a name='3.6'></a> 使用对象属性值的简写。</p>
<blockquote>
<p>为什么？因为这样更短更有描述性。</p>
</blockquote>
<pre><code>```javascript
const lukeSkywalker = 'Luke Skywalker';

// bad
const obj = {
  lukeSkywalker: lukeSkywalker,
};

// good
const obj = {
  lukeSkywalker,
};
```
</code></pre>
<ul>
<li><a href="#3.7">3.7</a> <a name='3.7'></a> 在对象属性声明前把简写的属性分组。</li>
</ul>
<blockquote>
<p>为什么？因为这样能清楚地看出哪些属性使用了简写。</p>
</blockquote>
<pre><code>```javascript
const anakinSkywalker = 'Anakin Skywalker';
const lukeSkywalker = 'Luke Skywalker';

// bad
const obj = {
  episodeOne: 1,
  twoJedisWalkIntoACantina: 2,
  lukeSkywalker,
  episodeThree: 3,
  mayTheFourth: 4,
  anakinSkywalker,
};

// good
const obj = {
  lukeSkywalker,
  anakinSkywalker,
  episodeOne: 1,
  twoJedisWalkIntoACantina: 2,
  episodeThree: 3,
  mayTheFourth: 4,
};
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="arrays"></a></p>
<h2 id="_5"><a name="user-content-_5" href="#_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>数组</h2>
<ul>
<li>
<p><a href="#4.1">4.1</a> <a name='4.1'></a> 使用字面值创建数组。</p>
<pre><code class="javascript">// bad
const items = new Array();

// good
const items = [];
</code></pre>

</li>
<li>
<p><a href="#4.2">4.2</a> <a name='4.2'></a> 向数组添加元素时使用 Arrary#push 替代直接赋值。</p>
<pre><code class="javascript">const someStack = [];


// bad
someStack[someStack.length] = 'abracadabra';

// good
someStack.push('abracadabra');
</code></pre>

</li>
</ul>
<p><a name="es6-array-spreads"></a><br />
  - <a href="#4.3">4.3</a> <a name='4.3'></a> 使用拓展运算符 <code>...</code> 复制数组。</p>
<pre><code>```javascript
// bad
const len = items.length;
const itemsCopy = [];
let i;

for (i = 0; i &lt; len; i++) {
  itemsCopy[i] = items[i];
}

// good
const itemsCopy = [...items];
```
</code></pre>
<ul>
<li>
<p><a href="#4.4">4.4</a> <a name='4.4'></a> 使用 Array#from 把一个类数组对象转换成数组。</p>
<pre><code class="javascript">const foo = document.querySelectorAll('.foo');
const nodes = Array.from(foo);
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="destructuring"></a></p>
<h2 id="_6"><a name="user-content-_6" href="#_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>解构</h2>
<ul>
<li><a href="#5.1">5.1</a> <a name='5.1'></a> 使用解构存取和使用多属性对象。</li>
</ul>
<blockquote>
<p>为什么？因为解构能减少临时引用属性。</p>
</blockquote>
<pre><code>```javascript
// bad
function getFullName(user) {
  const firstName = user.firstName;
  const lastName = user.lastName;

  return `${firstName} ${lastName}`;
}

// good
function getFullName(obj) {
  const { firstName, lastName } = obj;
  return `${firstName} ${lastName}`;
}

// best
function getFullName({ firstName, lastName }) {
  return `${firstName} ${lastName}`;
}
```
</code></pre>
<ul>
<li>
<p><a href="#5.2">5.2</a> <a name='5.2'></a> 对数组使用解构赋值。</p>
<pre><code class="javascript">const arr = [1, 2, 3, 4];

// bad
const first = arr[0];
const second = arr[1];

// good
const [first, second] = arr;
</code></pre>

</li>
<li>
<p><a href="#5.3">5.3</a> <a name='5.3'></a> 需要回传多个值时，使用对象解构，而不是数组解构。</p>
<blockquote>
<p>为什么？增加属性或者改变排序不会改变调用时的位置。</p>
</blockquote>
<pre><code class="javascript">// bad
function processInput(input) {
  // then a miracle occurs
  return [left, right, top, bottom];
}

// 调用时需要考虑回调数据的顺序。
const [left, __, top] = processInput(input);

// good
function processInput(input) {
  // then a miracle occurs
  return { left, right, top, bottom };
}

// 调用时只选择需要的数据
const { left, right } = processInput(input);
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="strings"></a></p>
<h2 id="strings"><a name="user-content-strings" href="#strings" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Strings</h2>
<ul>
<li>
<p><a href="#6.1">6.1</a> <a name='6.1'></a> 字符串使用单引号 <code>''</code> 。</p>
<pre><code class="javascript">// bad
const name = &quot;Capt. Janeway&quot;;

// good
const name = 'Capt. Janeway';
</code></pre>

</li>
<li>
<p><a href="#6.2">6.2</a> <a name='6.2'></a> 字符串超过 80 个字节应该使用字符串连接号换行。</p>
</li>
<li>
<p><a href="#6.3">6.3</a> <a name='6.3'></a> 注：过度使用字串连接符号可能会对性能造成影响。<a href="http://jsperf.com/ya-string-concat">jsPerf</a> 和 <a href="https://github.com/airbnb/javascript/issues/40">讨论</a>.</p>
<pre><code class="javascript">// bad
const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';

// bad
const errorMessage = 'This is a super long error that was thrown because \
of Batman. When you stop to think about how Batman had anything to do \
with this, you would get nowhere \
fast.';

// good
const errorMessage = 'This is a super long error that was thrown because ' +
  'of Batman. When you stop to think about how Batman had anything to do ' +
  'with this, you would get nowhere fast.';
</code></pre>

</li>
</ul>
<p><a name="es6-template-literals"></a><br />
  - <a href="#6.4">6.4</a> <a name='6.4'></a> 程序化生成字符串时，使用模板字符串代替字符串连接。</p>
<blockquote>
<p>为什么？模板字符串更为简洁，更具可读性。</p>
</blockquote>
<pre><code>```javascript
// bad
function sayHi(name) {
  return 'How are you, ' + name + '?';
}

// bad
function sayHi(name) {
  return ['How are you, ', name, '?'].join();
}

// good
function sayHi(name) {
  return `How are you, ${name}?`;
}
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="functions"></a></p>
<h2 id="_7"><a name="user-content-_7" href="#_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>函数</h2>
<ul>
<li><a href="#7.1">7.1</a> <a name='7.1'></a> 使用函数声明代替函数表达式。</li>
</ul>
<blockquote>
<p>为什么？因为函数声明是可命名的，所以他们在调用栈中更容易被识别。此外，函数声明会把整个函数提升（hoisted），而函数表达式只会把函数的引用变量名提升。这条规则使得<a href="#arrow-functions">箭头函数</a>可以取代函数表达式。</p>
</blockquote>
<pre><code>```javascript
// bad
const foo = function () {
};

// good
function foo() {
}
```
</code></pre>
<ul>
<li>
<p><a href="#7.2">7.2</a> <a name='7.2'></a> 函数表达式:</p>
<pre><code class="javascript">// 立即调用的函数表达式 (IIFE)
(() =&gt; {
  console.log('Welcome to the Internet. Please follow me.');
})();
</code></pre>

</li>
<li>
<p><a href="#7.3">7.3</a> <a name='7.3'></a> 永远不要在一个非函数代码块（<code>if</code>、<code>while</code> 等）中声明一个函数，把那个函数赋给一个变量。浏览器允许你这么做，但它们的解析表现不一致。</p>
</li>
<li>
<p><a href="#7.4">7.4</a> <a name='7.4'></a> <strong>注意:</strong> ECMA-262 把 <code>block</code> 定义为一组语句。函数声明不是语句。<a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97">阅读 ECMA-262 关于这个问题的说明</a>。</p>
<pre><code class="javascript">// bad
if (currentUser) {
  function test() {
    console.log('Nope.');
  }
}

// good
let test;
if (currentUser) {
  test = () =&gt; {
    console.log('Yup.');
  };
}
</code></pre>

</li>
<li>
<p><a href="#7.5">7.5</a> <a name='7.5'></a> 永远不要把参数命名为 <code>arguments</code>。这将取代原来函数作用域内的 <code>arguments</code> 对象。</p>
<pre><code class="javascript">// bad
function nope(name, options, arguments) {
  // ...stuff...
}

// good
function yup(name, options, args) {
  // ...stuff...
}
</code></pre>

</li>
</ul>
<p><a name="es6-rest"></a><br />
  - <a href="#7.6">7.6</a> <a name='7.6'></a> 不要使用 <code>arguments</code>。可以选择 rest 语法 <code>...</code> 替代。</p>
<blockquote>
<p>为什么？使用 <code>...</code> 能明确你要传入的参数。另外 rest 参数是一个真正的数组，而 <code>arguments</code> 是一个类数组。</p>
</blockquote>
<pre><code>```javascript
// bad
function concatenateAll() {
  const args = Array.prototype.slice.call(arguments);
  return args.join('');
}

// good
function concatenateAll(...args) {
  return args.join('');
}
```
</code></pre>
<p><a name="es6-default-parameters"></a><br />
  - <a href="#7.7">7.7</a> <a name='7.7'></a> 直接给函数的参数指定默认值，不要使用一个变化的函数参数。</p>
<pre><code>```javascript
// really bad
function handleThings(opts) {
  // 不！我们不应该改变函数参数。
  // 更加糟糕: 如果参数 opts 是 false 的话，它就会被设定为一个对象。
  // 但这样的写法会造成一些 Bugs。
  //（译注：例如当 opts 被赋值为空字符串，opts 仍然会被下一行代码设定为一个空对象。）
  opts = opts || {};
  // ...
}

// still bad
function handleThings(opts) {
  if (opts === void 0) {
    opts = {};
  }
  // ...
}

// good
function handleThings(opts = {}) {
  // ...
}
```
</code></pre>
<ul>
<li><a href="#7.8">7.8</a> <a name='7.8'></a> 直接给函数参数赋值时需要避免副作用。</li>
</ul>
<blockquote>
<p>为什么？因为这样的写法让人感到很困惑。</p>
</blockquote>
<pre><code class="javascript">var b = 1;
// bad
function count(a = b++) {
  console.log(a);
}
count();  // 1
count();  // 2
count(3); // 3
count();  // 3
</code></pre>

<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="arrow-functions"></a></p>
<h2 id="_8"><a name="user-content-_8" href="#_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>箭头函数</h2>
<ul>
<li><a href="#8.1">8.1</a> <a name='8.1'></a> 当你必须使用函数表达式（或传递一个匿名函数）时，使用箭头函数符号。</li>
</ul>
<blockquote>
<p>为什么?因为箭头函数创造了新的一个 <code>this</code> 执行环境（译注：参考 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">Arrow functions - JavaScript | MDN</a> 和 <a href="http://toddmotto.com/es6-arrow-functions-syntaxes-and-lexical-scoping/">ES6 arrow functions, syntax and lexical scoping</a>），通常情况下都能满足你的需求，而且这样的写法更为简洁。</p>
<p>为什么不？如果你有一个相当复杂的函数，你或许可以把逻辑部分转移到一个函数声明上。</p>
</blockquote>
<pre><code>```javascript
// bad
[1, 2, 3].map(function (x) {
  return x * x;
});

// good
[1, 2, 3].map((x) =&gt; {
  return x * x;
});
```
</code></pre>
<ul>
<li><a href="#8.2">8.2</a> <a name='8.2'></a> 如果一个函数适合用一行写出并且只有一个参数，那就把花括号、圆括号和 <code>return</code> 都省略掉。如果不是，那就不要省略。</li>
</ul>
<blockquote>
<p>为什么？语法糖。在链式调用中可读性很高。</p>
<p>为什么不？当你打算回传一个对象的时候。</p>
</blockquote>
<pre><code>```javascript
// good
[1, 2, 3].map(x =&gt; x * x);

// good
[1, 2, 3].reduce((total, n) =&gt; {
  return total + n;
}, 0);
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="constructors"></a></p>
<h2 id="_9"><a name="user-content-_9" href="#_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>构造器</h2>
<ul>
<li><a href="#9.1">9.1</a> <a name='9.1'></a> 总是使用 <code>class</code>。避免直接操作 <code>prototype</code> 。</li>
</ul>
<blockquote>
<p>为什么? 因为 <code>class</code> 语法更为简洁更易读。</p>
</blockquote>
<pre><code>```javascript
// bad
function Queue(contents = []) {
  this._queue = [...contents];
}
Queue.prototype.pop = function() {
  const value = this._queue[0];
  this._queue.splice(0, 1);
  return value;
}


// good
class Queue {
  constructor(contents = []) {
    this._queue = [...contents];
  }
  pop() {
    const value = this._queue[0];
    this._queue.splice(0, 1);
    return value;
  }
}
```
</code></pre>
<ul>
<li><a href="#9.2">9.2</a> <a name='9.2'></a> 使用 <code>extends</code> 继承。</li>
</ul>
<blockquote>
<p>为什么？因为 <code>extends</code> 是一个内建的原型继承方法并且不会破坏 <code>instanceof</code>。</p>
</blockquote>
<pre><code>```javascript
// bad
const inherits = require('inherits');
function PeekableQueue(contents) {
  Queue.apply(this, contents);
}
inherits(PeekableQueue, Queue);
PeekableQueue.prototype.peek = function() {
  return this._queue[0];
}

// good
class PeekableQueue extends Queue {
  peek() {
    return this._queue[0];
  }
}
```
</code></pre>
<ul>
<li>
<p><a href="#9.3">9.3</a> <a name='9.3'></a> 方法可以返回 <code>this</code> 来帮助链式调用。</p>
<pre><code class="javascript">// bad
Jedi.prototype.jump = function() {
  this.jumping = true;
  return true;
};

Jedi.prototype.setHeight = function(height) {
  this.height = height;
};

const luke = new Jedi();
luke.jump(); // =&gt; true
luke.setHeight(20); // =&gt; undefined

// good
class Jedi {
  jump() {
    this.jumping = true;
    return this;
  }

  setHeight(height) {
    this.height = height;
    return this;
  }
}

const luke = new Jedi();

luke.jump()
  .setHeight(20);
</code></pre>

</li>
<li>
<p><a href="#9.4">9.4</a> <a name='9.4'></a> 可以写一个自定义的 <code>toString()</code> 方法，但要确保它能正常运行并且不会引起副作用。</p>
<pre><code class="javascript">class Jedi {
  constructor(options = {}) {
    this.name = options.name || 'no name';
  }

  getName() {
    return this.name;
  }

  toString() {
    return `Jedi - ${this.getName()}`;
  }
}
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="modules"></a></p>
<h2 id="_10"><a name="user-content-_10" href="#_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>模块</h2>
<ul>
<li><a href="#10.1">10.1</a> <a name='10.1'></a> 总是使用模组 (<code>import</code>/<code>export</code>) 而不是其他非标准模块系统。你可以编译为你喜欢的模块系统。</li>
</ul>
<blockquote>
<p>为什么？模块就是未来，让我们开始迈向未来吧。</p>
</blockquote>
<pre><code>```javascript
// bad
const AirbnbStyleGuide = require('./AirbnbStyleGuide');
module.exports = AirbnbStyleGuide.es6;

// ok
import AirbnbStyleGuide from './AirbnbStyleGuide';
export default AirbnbStyleGuide.es6;

// best
import { es6 } from './AirbnbStyleGuide';
export default es6;
```
</code></pre>
<ul>
<li><a href="#10.2">10.2</a> <a name='10.2'></a> 不要使用通配符 import。</li>
</ul>
<blockquote>
<p>为什么？这样能确保你只有一个默认 export。</p>
</blockquote>
<pre><code>```javascript
// bad
import * as AirbnbStyleGuide from './AirbnbStyleGuide';

// good
import AirbnbStyleGuide from './AirbnbStyleGuide';
```
</code></pre>
<ul>
<li><a href="#10.3">10.3</a> <a name='10.3'></a>不要从 import 中直接 export。</li>
</ul>
<blockquote>
<p>为什么？虽然一行代码简洁明了，但让 import 和 export 各司其职让事情能保持一致。</p>
</blockquote>
<pre><code>```javascript
// bad
// filename es6.js
export { es6 as default } from './airbnbStyleGuide';

// good
// filename es6.js
import { es6 } from './AirbnbStyleGuide';
export default es6;
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="iterators-and-generators"></a></p>
<h2 id="iterators-and-generators"><a name="user-content-iterators-and-generators" href="#iterators-and-generators" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Iterators and Generators</h2>
<ul>
<li><a href="#11.1">11.1</a> <a name='11.1'></a> 不要使用 iterators。使用高阶函数例如 <code>map()</code> 和 <code>reduce()</code> 替代 <code>for-of</code>。</li>
</ul>
<blockquote>
<p>为什么？这加强了我们不变的规则。处理纯函数的回调值更易读，这比它带来的副作用更重要。</p>
</blockquote>
<pre><code>```javascript
const numbers = [1, 2, 3, 4, 5];

// bad
let sum = 0;
for (let num of numbers) {
  sum += num;
}

sum === 15;

// good
let sum = 0;
numbers.forEach((num) =&gt; sum += num);
sum === 15;

// best (use the functional force)
const sum = numbers.reduce((total, num) =&gt; total + num, 0);
sum === 15;
```
</code></pre>
<ul>
<li><a href="#11.2">11.2</a> <a name='11.2'></a> 现在还不要使用 generators。</li>
</ul>
<blockquote>
<p>为什么？因为它们现在还没法很好地编译到 ES5。 (译者注：目前(2016/03) Chrome 和 Node.js 的稳定版本都已支持 generators)</p>
</blockquote>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="properties"></a></p>
<h2 id="_11"><a name="user-content-_11" href="#_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>属性</h2>
<ul>
<li>
<p><a href="#12.1">12.1</a> <a name='12.1'></a> 使用 <code>.</code> 来访问对象的属性。</p>
<pre><code class="javascript">const luke = {
  jedi: true,
  age: 28,
};

// bad
const isJedi = luke['jedi'];

// good
const isJedi = luke.jedi;
</code></pre>

</li>
<li>
<p><a href="#12.2">12.2</a> <a name='12.2'></a> 当通过变量访问属性时使用中括号 <code>[]</code>。</p>
<pre><code class="javascript">const luke = {
  jedi: true,
  age: 28,
};

function getProp(prop) {
  return luke[prop];
}

const isJedi = getProp('jedi');
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="variables"></a></p>
<h2 id="_12"><a name="user-content-_12" href="#_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>变量</h2>
<ul>
<li>
<p><a href="#13.1">13.1</a> <a name='13.1'></a> 一直使用 <code>const</code> 来声明变量，如果不这样做就会产生全局变量。我们需要避免全局命名空间的污染。<a href="http://www.wikiwand.com/en/Captain_Planet">地球队长</a>已经警告过我们了。（译注：全局，global 亦有全球的意思。地球队长的责任是保卫地球环境，所以他警告我们不要造成「全球」污染。）</p>
<pre><code class="javascript">// bad
superPower = new SuperPower();

// good
const superPower = new SuperPower();
</code></pre>

</li>
<li>
<p><a href="#13.2">13.2</a> <a name='13.2'></a> 使用 <code>const</code> 声明每一个变量。</p>
<blockquote>
<p>为什么？增加新变量将变的更加容易，而且你永远不用再担心调换错 <code>;</code> 跟 <code>,</code>。</p>
</blockquote>
<pre><code class="javascript">// bad
const items = getItems(),
    goSportsTeam = true,
    dragonball = 'z';

// bad
// (compare to above, and try to spot the mistake)
const items = getItems(),
    goSportsTeam = true;
    dragonball = 'z';

// good
const items = getItems();
const goSportsTeam = true;
const dragonball = 'z';
</code></pre>

</li>
<li>
<p><a href="#13.3">13.3</a> <a name='13.3'></a> 将所有的 <code>const</code> 和 <code>let</code> 分组</p>
</li>
</ul>
<blockquote>
<p>为什么？当你需要把已赋值变量赋值给未赋值变量时非常有用。</p>
</blockquote>
<pre><code>```javascript
// bad
let i, len, dragonball,
    items = getItems(),
    goSportsTeam = true;

// bad
let i;
const items = getItems();
let dragonball;
const goSportsTeam = true;
let len;

// good
const goSportsTeam = true;
const items = getItems();
let dragonball;
let i;
let length;
```
</code></pre>
<ul>
<li><a href="#13.4">13.4</a> <a name='13.4'></a> 在你需要的地方给变量赋值，但请把它们放在一个合理的位置。</li>
</ul>
<blockquote>
<p>为什么？<code>let</code> 和 <code>const</code> 是块级作用域而不是函数作用域。</p>
</blockquote>
<pre><code>```javascript
// good
function() {
  test();
  console.log('doing stuff..');

  //..other stuff..

  const name = getName();

  if (name === 'test') {
    return false;
  }

  return name;
}

// bad - unnecessary function call
function(hasName) {
  const name = getName();

  if (!hasName) {
    return false;
  }

  this.setFirstName(name);

  return true;
}

// good
function(hasName) {
  if (!hasName) {
    return false;
  }

  const name = getName();
  this.setFirstName(name);

  return true;
}
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="hoisting"></a></p>
<h2 id="hoisting"><a name="user-content-hoisting" href="#hoisting" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Hoisting</h2>
<ul>
<li>
<p><a href="#14.1">14.1</a> <a name='14.1'></a> <code>var</code> 声明会被提升至该作用域的顶部，但它们赋值不会提升。<code>let</code> 和 <code>const</code> 被赋予了一种称为「<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let">暂时性死区（Temporal Dead Zones, TDZ）</a>」的概念。这对于了解为什么 <a href="http://es-discourse.com/t/why-typeof-is-no-longer-safe/15">type of 不再安全</a>相当重要。</p>
<pre><code class="javascript">// 我们知道这样运行不了
// （假设 notDefined 不是全局变量）
function example() {
  console.log(notDefined); // =&gt; throws a ReferenceError
}

// 由于变量提升的原因，
// 在引用变量后再声明变量是可以运行的。
// 注：变量的赋值 `true` 不会被提升。
function example() {
  console.log(declaredButNotAssigned); // =&gt; undefined
  var declaredButNotAssigned = true;
}

// 编译器会把函数声明提升到作用域的顶层，
// 这意味着我们的例子可以改写成这样：
function example() {
  let declaredButNotAssigned;
  console.log(declaredButNotAssigned); // =&gt; undefined
  declaredButNotAssigned = true;
}

// 使用 const 和 let
function example() {
  console.log(declaredButNotAssigned); // =&gt; throws a ReferenceError
  console.log(typeof declaredButNotAssigned); // =&gt; throws a ReferenceError
  const declaredButNotAssigned = true;
}
</code></pre>

</li>
<li>
<p><a href="#14.2">14.2</a> <a name='14.2'></a> 匿名函数表达式的变量名会被提升，但函数内容并不会。</p>
<pre><code class="javascript">function example() {
  console.log(anonymous); // =&gt; undefined

  anonymous(); // =&gt; TypeError anonymous is not a function

  var anonymous = function() {
    console.log('anonymous function expression');
  };
}
</code></pre>

</li>
<li>
<p><a href="#14.3">14.3</a> <a name='14.3'></a> 命名的函数表达式的变量名会被提升，但函数名和函数函数内容并不会。</p>
<pre><code class="javascript">function example() {
  console.log(named); // =&gt; undefined

  named(); // =&gt; TypeError named is not a function

  superPower(); // =&gt; ReferenceError superPower is not defined

  var named = function superPower() {
    console.log('Flying');
  };
}

// the same is true when the function name
// is the same as the variable name.
function example() {
  console.log(named); // =&gt; undefined

  named(); // =&gt; TypeError named is not a function

  var named = function named() {
    console.log('named');
  }
}
</code></pre>

</li>
<li>
<p><a href="#14.4">14.4</a> <a name='14.4'></a> 函数声明的名称和函数体都会被提升。</p>
<pre><code class="javascript">function example() {
  superPower(); // =&gt; Flying

  function superPower() {
    console.log('Flying');
  }
}
</code></pre>

</li>
<li>
<p>想了解更多信息，参考 <a href="http://www.adequatelygood.com/">Ben Cherry</a> 的 <a href="http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting">JavaScript Scoping &amp; Hoisting</a>。</p>
</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="comparison-operators--equality"></a></p>
<h2 id="_13"><a name="user-content-_13" href="#_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>比较运算符 &amp; 等号</h2>
<ul>
<li><a href="#15.1">15.1</a> <a name='15.1'></a> 优先使用 <code>===</code> 和 <code>!==</code> 而不是 <code>==</code> 和 <code>!=</code>.</li>
<li>
<p><a href="#15.2">15.2</a> <a name='15.2'></a> 条件表达式例如 <code>if</code> 语句通过抽象方法 <code>ToBoolean</code> 强制计算它们的表达式并且总是遵守下面的规则：</p>
<ul>
<li><strong>对象</strong> 被计算为 <strong>true</strong></li>
<li><strong>Undefined</strong> 被计算为 <strong>false</strong></li>
<li><strong>Null</strong> 被计算为 <strong>false</strong></li>
<li><strong>布尔值</strong> 被计算为 <strong>布尔的值</strong></li>
<li><strong>数字</strong> 如果是 <strong>+0、-0、或 NaN</strong> 被计算为 <strong>false</strong>, 否则为 <strong>true</strong></li>
<li><strong>字符串</strong> 如果是空字符串 <code>''</code> 被计算为 <strong>false</strong>，否则为 <strong>true</strong></li>
</ul>
<pre><code class="javascript">if ([0]) {
  // true
  // An array is an object, objects evaluate to true
}
</code></pre>

</li>
<li>
<p><a href="#15.3">15.3</a> <a name='15.3'></a> 使用简写。</p>
<pre><code class="javascript">// bad
if (name !== '') {
  // ...stuff...
}

// good
if (name) {
  // ...stuff...
}

// bad
if (collection.length &gt; 0) {
  // ...stuff...
}

// good
if (collection.length) {
  // ...stuff...
}
</code></pre>

</li>
<li>
<p><a href="#15.4">15.4</a> <a name='15.4'></a> 想了解更多信息，参考 Angus Croll 的 <a href="http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108">Truth Equality and JavaScript</a>。</p>
</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="blocks"></a></p>
<h2 id="_14"><a name="user-content-_14" href="#_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>代码块</h2>
<ul>
<li>
<p><a href="#16.1">16.1</a> <a name='16.1'></a> 使用大括号包裹所有的多行代码块。</p>
<pre><code class="javascript">// bad
if (test)
  return false;

// good
if (test) return false;

// good
if (test) {
  return false;
}

// bad
function() { return false; }

// good
function() {
  return false;
}
</code></pre>

</li>
<li>
<p><a href="#16.2">16.2</a> <a name='16.2'></a> 如果通过 <code>if</code> 和 <code>else</code> 使用多行代码块，把 <code>else</code> 放在 <code>if</code> 代码块关闭括号的同一行。</p>
<pre><code class="javascript">// bad
if (test) {
  thing1();
  thing2();
}
else {
  thing3();
}

// good
if (test) {
  thing1();
  thing2();
} else {
  thing3();
}
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="comments"></a></p>
<h2 id="_15"><a name="user-content-_15" href="#_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>注释</h2>
<ul>
<li>
<p><a href="#17.1">17.1</a> <a name='17.1'></a> 使用 <code>/** ... */</code> 作为多行注释。包含描述、指定所有参数和返回值的类型和值。</p>
<pre><code class="javascript">// bad
// make() returns a new element
// based on the passed in tag name
//
// @param {String} tag
// @return {Element} element
function make(tag) {

  // ...stuff...

  return element;
}

// good
/**
 * make() returns a new element
 * based on the passed in tag name
 *
 * @param {String} tag
 * @return {Element} element
 */
function make(tag) {

  // ...stuff...

  return element;
}
</code></pre>

</li>
<li>
<p><a href="#17.2">17.2</a> <a name='17.2'></a> 使用 <code>//</code> 作为单行注释。在评论对象上面另起一行使用单行注释。在注释前插入空行。</p>
<pre><code class="javascript">// bad
const active = true;  // is current tab

// good
// is current tab
const active = true;

// bad
function getType() {
  console.log('fetching type...');
  // set the default type to 'no type'
  const type = this._type || 'no type';

  return type;
}

// good
function getType() {
  console.log('fetching type...');

  // set the default type to 'no type'
  const type = this._type || 'no type';

  return type;
}
</code></pre>

</li>
<li>
<p><a href="#17.3">17.3</a> <a name='17.3'></a> 给注释增加 <code>FIXME</code> 或 <code>TODO</code> 的前缀可以帮助其他开发者快速了解这是一个需要复查的问题，或是给需要实现的功能提供一个解决方式。这将有别于常见的注释，因为它们是可操作的。使用 <code>FIXME -- need to figure this out</code> 或者 <code>TODO -- need to implement</code>。</p>
</li>
<li>
<p><a href="#17.4">17.4</a> <a name='17.4'></a> 使用 <code>// FIXME</code>: 标注问题。</p>
<pre><code class="javascript">class Calculator {
  constructor() {
    // FIXME: shouldn't use a global here
    total = 0;
  }
}
</code></pre>

</li>
<li>
<p><a href="#17.5">17.5</a> <a name='17.5'></a> 使用 <code>// TODO</code>: 标注问题的解决方式。</p>
<pre><code class="javascript">class Calculator {
  constructor() {
    // TODO: total should be configurable by an options param
    this.total = 0;
  }
}
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="whitespace"></a></p>
<h2 id="_16"><a name="user-content-_16" href="#_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>空白</h2>
<ul>
<li>
<p><a href="#18.1">18.1</a> <a name='18.1'></a> 使用 2 个空格作为缩进。</p>
<pre><code class="javascript">// bad
function() {
∙∙∙∙const name;
}

// bad
function() {
∙const name;
}

// good
function() {
∙∙const name;
}
</code></pre>

</li>
<li>
<p><a href="#18.2">18.2</a> <a name='18.2'></a> 在花括号前放一个空格。</p>
<pre><code class="javascript">// bad
function test(){
  console.log('test');
}

// good
function test() {
  console.log('test');
}

// bad
dog.set('attr',{
  age: '1 year',
  breed: 'Bernese Mountain Dog',
});

// good
dog.set('attr', {
  age: '1 year',
  breed: 'Bernese Mountain Dog',
});
</code></pre>

</li>
<li>
<p><a href="#18.3">18.3</a> <a name='18.3'></a> 在控制语句（<code>if</code>、<code>while</code> 等）的小括号前放一个空格。在函数调用及声明中，不在函数的参数列表前加空格。</p>
<pre><code class="javascript">// bad
if(isJedi) {
  fight ();
}

// good
if (isJedi) {
  fight();
}

// bad
function fight () {
  console.log ('Swooosh!');
}

// good
function fight() {
  console.log('Swooosh!');
}
</code></pre>

</li>
<li>
<p><a href="#18.4">18.4</a> <a name='18.4'></a> 使用空格把运算符隔开。</p>
<pre><code class="javascript">// bad
const x=y+5;

// good
const x = y + 5;
</code></pre>

</li>
<li>
<p><a href="#18.5">18.5</a> <a name='18.5'></a> 在文件末尾插入一个空行。</p>
<pre><code class="javascript">// bad
(function(global) {
  // ...stuff...
})(this);
</code></pre>

<pre><code class="javascript">// bad
(function(global) {
  // ...stuff...
})(this);↵
↵
</code></pre>

<pre><code class="javascript">// good
(function(global) {
  // ...stuff...
})(this);↵
</code></pre>

</li>
<li>
<p><a href="#18.5">18.5</a> <a name='18.5'></a> 在使用长方法链时进行缩进。使用前面的点 <code>.</code> 强调这是方法调用而不是新语句。</p>
<pre><code class="javascript">// bad
$('#items').find('.selected').highlight().end().find('.open').updateCount();

// bad
$('#items').
  find('.selected').
    highlight().
    end().
  find('.open').
    updateCount();

// good
$('#items')
  .find('.selected')
    .highlight()
    .end()
  .find('.open')
    .updateCount();

// bad
const leds = stage.selectAll('.led').data(data).enter().append('svg:svg').class('led', true)
    .attr('width', (radius + margin) * 2).append('svg:g')
    .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')')
    .call(tron.led);

// good
const leds = stage.selectAll('.led')
    .data(data)
  .enter().append('svg:svg')
    .classed('led', true)
    .attr('width', (radius + margin) * 2)
  .append('svg:g')
    .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')')
    .call(tron.led);
</code></pre>

</li>
<li>
<p><a href="#18.6">18.6</a> <a name='18.6'></a> 在块末和新语句前插入空行。</p>
<pre><code class="javascript">// bad
if (foo) {
  return bar;
}
return baz;

// good
if (foo) {
  return bar;
}

return baz;

// bad
const obj = {
  foo() {
  },
  bar() {
  },
};
return obj;

// good
const obj = {
  foo() {
  },

  bar() {
  },
};

return obj;
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="commas"></a></p>
<h2 id="_17"><a name="user-content-_17" href="#_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>逗号</h2>
<ul>
<li>
<p><a href="#19.1">19.1</a> <a name='19.1'></a> 行首逗号：<strong>不需要</strong>。</p>
<pre><code class="javascript">// bad
const story = [
    once
  , upon
  , aTime
];

// good
const story = [
  once,
  upon,
  aTime,
];

// bad
const hero = {
    firstName: 'Ada'
  , lastName: 'Lovelace'
  , birthYear: 1815
  , superPower: 'computers'
};

// good
const hero = {
  firstName: 'Ada',
  lastName: 'Lovelace',
  birthYear: 1815,
  superPower: 'computers',
};
</code></pre>

</li>
<li>
<p><a href="#19.2">19.2</a> <a name='19.2'></a> 增加结尾的逗号: <strong>需要</strong>。</p>
</li>
</ul>
<blockquote>
<p>为什么? 这会让 git diffs 更干净。另外，像 babel 这样的转译器会移除结尾多余的逗号，也就是说你不必担心老旧浏览器的<a href="es5/README.md#commas">尾逗号问题</a>。</p>
</blockquote>
<pre><code>```javascript
// bad - git diff without trailing comma
const hero = {
     firstName: 'Florence',
-    lastName: 'Nightingale'
+    lastName: 'Nightingale',
+    inventorOf: ['coxcomb graph', 'modern nursing']
}

// good - git diff with trailing comma
const hero = {
     firstName: 'Florence',
     lastName: 'Nightingale',
+    inventorOf: ['coxcomb chart', 'modern nursing'],
}

// bad
const hero = {
  firstName: 'Dana',
  lastName: 'Scully'
};

const heroes = [
  'Batman',
  'Superman'
];

// good
const hero = {
  firstName: 'Dana',
  lastName: 'Scully',
};

const heroes = [
  'Batman',
  'Superman',
];
```
</code></pre>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="semicolons"></a></p>
<h2 id="_18"><a name="user-content-_18" href="#_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>分号</h2>
<ul>
<li>
<p><a href="#20.1">20.1</a> <a name='20.1'></a> <strong>使用分号</strong></p>
<pre><code class="javascript">// bad
(function() {
  const name = 'Skywalker'
  return name
})()

// good
(() =&gt; {
  const name = 'Skywalker';
  return name;
})();

// good (防止函数在两个 IIFE 合并时被当成一个参数)
;(() =&gt; {
  const name = 'Skywalker';
  return name;
})();
</code></pre>

<p><a href="http://stackoverflow.com/a/7365214/1712802">Read more</a>.</p>
</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="type-casting--coercion"></a></p>
<h2 id="_19"><a name="user-content-_19" href="#_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>类型转换</h2>
<ul>
<li><a href="#21.1">21.1</a> <a name='21.1'></a> 在语句开始时执行类型转换。</li>
<li>
<p><a href="#21.2">21.2</a> <a name='21.2'></a> 字符串：</p>
<pre><code class="javascript">//  =&gt; this.reviewScore = 9;

// bad
const totalScore = this.reviewScore + '';

// good
const totalScore = String(this.reviewScore);
</code></pre>

</li>
<li>
<p><a href="#21.3">21.3</a> <a name='21.3'></a> 对数字使用 <code>parseInt</code> 转换，并带上类型转换的基数。</p>
<pre><code class="javascript">const inputValue = '4';

// bad
const val = new Number(inputValue);

// bad
const val = +inputValue;

// bad
const val = inputValue &gt;&gt; 0;

// bad
const val = parseInt(inputValue);

// good
const val = Number(inputValue);

// good
const val = parseInt(inputValue, 10);
</code></pre>

</li>
<li>
<p><a href="#21.4">21.4</a> <a name='21.4'></a> 如果因为某些原因 parseInt 成为你所做的事的瓶颈而需要使用位操作解决<a href="http://jsperf.com/coercion-vs-casting/3">性能问题</a>时，留个注释说清楚原因和你的目的。</p>
<pre><code class="javascript">// good
/**
 * 使用 parseInt 导致我的程序变慢，
 * 改成使用位操作转换数字快多了。
 */
const val = inputValue &gt;&gt; 0;
</code></pre>

</li>
<li>
<p><a href="#21.5">21.5</a> <a name='21.5'></a> <strong>注:</strong> 小心使用位操作运算符。数字会被当成 <a href="http://es5.github.io/#x4.3.19">64 位值</a>，但是位操作运算符总是返回 32 位的整数（<a href="http://es5.github.io/#x11.7">参考</a>）。位操作处理大于 32 位的整数值时还会导致意料之外的行为。<a href="https://github.com/airbnb/javascript/issues/109">关于这个问题的讨论</a>。最大的 32 位整数是 2,147,483,647：</p>
<pre><code class="javascript">2147483647 &gt;&gt; 0 //=&gt; 2147483647
2147483648 &gt;&gt; 0 //=&gt; -2147483648
2147483649 &gt;&gt; 0 //=&gt; -2147483647
</code></pre>

</li>
<li>
<p><a href="#21.6">21.6</a> <a name='21.6'></a> 布尔:</p>
<pre><code class="javascript">const age = 0;

// bad
const hasAge = new Boolean(age);

// good
const hasAge = Boolean(age);

// good
const hasAge = !!age;
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="naming-conventions"></a></p>
<h2 id="_20"><a name="user-content-_20" href="#_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>命名规则</h2>
<ul>
<li>
<p><a href="#22.1">22.1</a> <a name='22.1'></a> 避免单字母命名。命名应具备描述性。</p>
<pre><code class="javascript">// bad
function q() {
  // ...stuff...
}

// good
function query() {
  // ..stuff..
}
</code></pre>

</li>
<li>
<p><a href="#22.2">22.2</a> <a name='22.2'></a> 使用驼峰式命名对象、函数和实例。</p>
<pre><code class="javascript">// bad
const OBJEcttsssss = {};
const this_is_my_object = {};
function c() {}

// good
const thisIsMyObject = {};
function thisIsMyFunction() {}
</code></pre>

</li>
<li>
<p><a href="#22.3">22.3</a> <a name='22.3'></a> 使用帕斯卡式命名构造函数或类。</p>
<pre><code class="javascript">// bad
function user(options) {
  this.name = options.name;
}

const bad = new user({
  name: 'nope',
});

// good
class User {
  constructor(options) {
    this.name = options.name;
  }
}

const good = new User({
  name: 'yup',
});
</code></pre>

</li>
<li>
<p><a href="#22.4">22.4</a> <a name='22.4'></a> 使用下划线 <code>_</code> 开头命名私有属性。</p>
<pre><code class="javascript">// bad
this.__firstName__ = 'Panda';
this.firstName_ = 'Panda';

// good
this._firstName = 'Panda';
</code></pre>

</li>
<li>
<p><a href="#22.5">22.5</a> <a name='22.5'></a> 别保存 <code>this</code> 的引用。使用箭头函数或 Function#bind。</p>
<pre><code class="javascript">// bad
function foo() {
  const self = this;
  return function() {
    console.log(self);
  };
}

// bad
function foo() {
  const that = this;
  return function() {
    console.log(that);
  };
}

// good
function foo() {
  return () =&gt; {
    console.log(this);
  };
}
</code></pre>

</li>
<li>
<p><a href="#22.6">22.6</a> <a name='22.6'></a> 如果你的文件只输出一个类，那你的文件名必须和类名完全保持一致。</p>
<pre><code class="javascript">// file contents
class CheckBox {
  // ...
}
export default CheckBox;

// in some other file
// bad
import CheckBox from './checkBox';

// bad
import CheckBox from './check_box';

// good
import CheckBox from './CheckBox';
</code></pre>

</li>
<li>
<p><a href="#22.7">22.7</a> <a name='22.7'></a> 当你导出默认的函数时使用驼峰式命名。你的文件名必须和函数名完全保持一致。</p>
<pre><code class="javascript">function makeStyleGuide() {
}

export default makeStyleGuide;
</code></pre>

</li>
<li>
<p><a href="#22.8">22.8</a> <a name='22.8'></a> 当你导出单例、函数库、空对象时使用帕斯卡式命名。</p>
<pre><code class="javascript">const AirbnbStyleGuide = {
  es6: {
  }
};

export default AirbnbStyleGuide;
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="accessors"></a></p>
<h2 id="_21"><a name="user-content-_21" href="#_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>存取器</h2>
<ul>
<li><a href="#23.1">23.1</a> <a name='23.1'></a> 属性的存取函数不是必须的。</li>
<li>
<p><a href="#23.2">23.2</a> <a name='23.2'></a> 如果你需要存取函数时使用 <code>getVal()</code> 和 <code>setVal('hello')</code>。</p>
<pre><code class="javascript">// bad
dragon.age();

// good
dragon.getAge();

// bad
dragon.age(25);

// good
dragon.setAge(25);
</code></pre>

</li>
<li>
<p><a href="#23.3">23.3</a> <a name='23.3'></a> 如果属性是布尔值，使用 <code>isVal()</code> 或 <code>hasVal()</code>。</p>
<pre><code class="javascript">// bad
if (!dragon.age()) {
  return false;
}

// good
if (!dragon.hasAge()) {
  return false;
}
</code></pre>

</li>
<li>
<p><a href="#23.4">23.4</a> <a name='23.4'></a> 创建 <code>get()</code> 和 <code>set()</code> 函数是可以的，但要保持一致。</p>
<pre><code class="javascript">class Jedi {
  constructor(options = {}) {
    const lightsaber = options.lightsaber || 'blue';
    this.set('lightsaber', lightsaber);
  }

  set(key, val) {
    this[key] = val;
  }

  get(key) {
    return this[key];
  }
}
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="events"></a></p>
<h2 id="_22"><a name="user-content-_22" href="#_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>事件</h2>
<ul>
<li>
<p><a href="#24.1">24.1</a> <a name='24.1'></a> 当给事件附加数据时（无论是 DOM 事件还是私有事件），传入一个哈希而不是原始值。这样可以让后面的贡献者增加更多数据到事件数据而无需找出并更新事件的每一个处理器。例如，不好的写法：</p>
<pre><code class="javascript">// bad
$(this).trigger('listingUpdated', listing.id);

...

$(this).on('listingUpdated', function(e, listingId) {
  // do something with listingId
});
</code></pre>

<p>更好的写法：</p>
<pre><code class="javascript">// good
$(this).trigger('listingUpdated', { listingId : listing.id });

...

$(this).on('listingUpdated', function(e, data) {
  // do something with data.listingId
});
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<h2 id="jquery"><a name="user-content-jquery" href="#jquery" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>jQuery</h2>
<ul>
<li>
<p><a href="#25.1">25.1</a> <a name='25.1'></a> 使用 <code>$</code> 作为存储 jQuery 对象的变量名前缀。</p>
<pre><code class="javascript">// bad
const sidebar = $('.sidebar');

// good
const $sidebar = $('.sidebar');
</code></pre>

</li>
<li>
<p><a href="#25.2">25.2</a> <a name='25.2'></a> 缓存 jQuery 查询。</p>
<pre><code class="javascript">// bad
function setSidebar() {
  $('.sidebar').hide();

  // ...stuff...

  $('.sidebar').css({
    'background-color': 'pink'
  });
}

// good
function setSidebar() {
  const $sidebar = $('.sidebar');
  $sidebar.hide();

  // ...stuff...

  $sidebar.css({
    'background-color': 'pink'
  });
}
</code></pre>

</li>
<li>
<p><a href="#25.3">25.3</a> <a name='25.3'></a> 对 DOM 查询使用层叠 <code>$('.sidebar ul')</code> 或 父元素 &gt; 子元素 <code>$('.sidebar &gt; ul')</code>。 <a href="http://jsperf.com/jquery-find-vs-context-sel/16">jsPerf</a></p>
</li>
<li>
<p><a href="#25.4">25.4</a> <a name='25.4'></a> 对有作用域的 jQuery 对象查询使用 <code>find</code>。</p>
<pre><code class="javascript">// bad
$('ul', '.sidebar').hide();

// bad
$('.sidebar').find('ul').hide();

// good
$('.sidebar ul').hide();

// good
$('.sidebar &gt; ul').hide();

// good
$sidebar.find('ul').hide();
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="ecmascript-5-compatibility"></a></p>
<h2 id="ecmascript-5"><a name="user-content-ecmascript-5" href="#ecmascript-5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>ECMAScript 5 兼容性</h2>
<ul>
<li><a href="#26.1">26.1</a> <a name='26.1'></a> 参考 <a href="https://twitter.com/kangax/">Kangax</a> 的 ES5 <a href="http://kangax.github.com/es5-compat-table/">兼容性</a>.</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="ecmascript-6-styles"></a></p>
<h2 id="ecmascript-6"><a name="user-content-ecmascript-6" href="#ecmascript-6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>ECMAScript 6 规范</h2>
<ul>
<li><a href="#27.1">27.1</a> <a name='27.1'></a> 以下是链接到 ES6 的各个特性的列表。</li>
</ul>
<ol>
<li><a href="#arrow-functions">Arrow Functions</a></li>
<li><a href="#constructors">Classes</a></li>
<li><a href="#es6-object-shorthand">Object Shorthand</a></li>
<li><a href="#es6-object-concise">Object Concise</a></li>
<li><a href="#es6-computed-properties">Object Computed Properties</a></li>
<li><a href="#es6-template-literals">Template Strings</a></li>
<li><a href="#destructuring">Destructuring</a></li>
<li><a href="#es6-default-parameters">Default Parameters</a></li>
<li><a href="#es6-rest">Rest</a></li>
<li><a href="#es6-array-spreads">Array Spreads</a></li>
<li><a href="#references">Let and Const</a></li>
<li><a href="#iterators-and-generators">Iterators and Generators</a></li>
<li><a href="#modules">Modules</a></li>
</ol>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="testing"></a></p>
<h2 id="_23"><a name="user-content-_23" href="#_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>测试</h2>
<ul>
<li>
<p><a href="#28.1">28.1</a> <a name='28.1'></a> <strong>Yup.</strong></p>
<pre><code class="javascript">function() {
  return true;
}
</code></pre>

</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="performance"></a></p>
<h2 id="_24"><a name="user-content-_24" href="#_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>性能</h2>
<ul>
<li><a href="http://kellegous.com/j/2013/01/26/layout-performance/">On Layout &amp; Web Performance</a></li>
<li><a href="http://jsperf.com/string-vs-array-concat/2">String vs Array Concat</a></li>
<li><a href="http://jsperf.com/try-catch-in-loop-cost">Try/Catch Cost In a Loop</a></li>
<li><a href="http://jsperf.com/bang-function">Bang Function</a></li>
<li><a href="http://jsperf.com/jquery-find-vs-context-sel/13">jQuery Find vs Context, Selector</a></li>
<li><a href="http://jsperf.com/innerhtml-vs-textcontent-for-script-text">innerHTML vs textContent for script text</a></li>
<li><a href="http://jsperf.com/ya-string-concat">Long String Concatenation</a></li>
<li>Loading&hellip;</li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<p><a name="resources"></a></p>
<h2 id="_25"><a name="user-content-_25" href="#_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>资源</h2>
<p><strong>Learning ES6</strong></p>
<ul>
<li><a href="https://people.mozilla.org/~jorendorff/es6-draft.html">Draft ECMA 2015 (ES6) Spec</a></li>
<li><a href="http://exploringjs.com/">ExploringJS</a></li>
<li><a href="https://kangax.github.io/compat-table/es6/">ES6 Compatibility Table</a></li>
<li><a href="http://es6-features.org/">Comprehensive Overview of ES6 Features</a></li>
</ul>
<p><strong>Read This</strong></p>
<ul>
<li><a href="http://es5.github.com/">Annotated ECMAScript 5.1</a></li>
</ul>
<p><strong>Tools</strong></p>
<ul>
<li>Code Style Linters<ul>
<li><a href="http://eslint.org/">ESlint</a> - <a href="https://github.com/airbnb/javascript/blob/master/linters/.eslintrc">Airbnb Style .eslintrc</a></li>
<li><a href="http://www.jshint.com/">JSHint</a> - <a href="https://github.com/airbnb/javascript/blob/master/linters/jshintrc">Airbnb Style .jshintrc</a></li>
<li><a href="https://github.com/jscs-dev/node-jscs">JSCS</a> - <a href="https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json">Airbnb Style Preset</a></li>
</ul>
</li>
</ul>
<p><strong>Other Styleguides</strong></p>
<ul>
<li><a href="http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml">Google JavaScript Style Guide</a></li>
<li><a href="http://docs.jquery.com/JQuery_Core_Style_Guidelines">jQuery Core Style Guidelines</a></li>
<li><a href="https://github.com/rwldrn/idiomatic.js/">Principles of Writing Consistent, Idiomatic JavaScript</a></li>
</ul>
<p><strong>Other Styles</strong></p>
<ul>
<li><a href="https://gist.github.com/4135065">Naming this in nested functions</a> - Christian Johansen</li>
<li><a href="https://github.com/airbnb/javascript/issues/52">Conditional Callbacks</a> - Ross Allen</li>
<li><a href="http://sideeffect.kr/popularconvention/#javascript">Popular JavaScript Coding Conventions on Github</a> - JeongHoon Byun</li>
<li><a href="http://benalman.com/news/2012/05/multiple-var-statements-javascript/">Multiple var statements in JavaScript, not superfluous</a> - Ben Alman</li>
</ul>
<p><strong>Further Reading</strong></p>
<ul>
<li><a href="http://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/">Understanding JavaScript Closures</a> - Angus Croll</li>
<li><a href="http://www.2ality.com/2013/06/basic-javascript.html">Basic JavaScript for the impatient programmer</a> - Dr. Axel Rauschmayer</li>
<li><a href="http://youmightnotneedjquery.com/">You Might Not Need jQuery</a> - Zack Bloom &amp; Adam Schwartz</li>
<li><a href="https://github.com/lukehoban/es6features">ES6 Features</a> - Luke Hoban</li>
<li><a href="https://github.com/bendc/frontend-guidelines">Frontend Guidelines</a> - Benjamin De Cock</li>
</ul>
<p><strong>Books</strong></p>
<ul>
<li><a href="http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742">JavaScript: The Good Parts</a> - Douglas Crockford</li>
<li><a href="http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752">JavaScript Patterns</a> - Stoyan Stefanov</li>
<li><a href="http://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X">Pro JavaScript Design Patterns</a>  - Ross Harmes and Dustin Diaz</li>
<li><a href="http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309">High Performance Web Sites: Essential Knowledge for Front-End Engineers</a> - Steve Souders</li>
<li><a href="http://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680">Maintainable JavaScript</a> - Nicholas C. Zakas</li>
<li><a href="http://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X">JavaScript Web Applications</a> - Alex MacCaw</li>
<li><a href="http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273">Pro JavaScript Techniques</a> - John Resig</li>
<li><a href="http://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595">Smashing Node.js: JavaScript Everywhere</a> - Guillermo Rauch</li>
<li><a href="http://www.amazon.com/Secrets-JavaScript-Ninja-John-Resig/dp/193398869X">Secrets of the JavaScript Ninja</a> - John Resig and Bear Bibeault</li>
<li><a href="http://humanjavascript.com/">Human JavaScript</a> - Henrik Joreteg</li>
<li><a href="http://superherojs.com/">Superhero.js</a> - Kim Joar Bekkelund, Mads Mobæk, &amp; Olav Bjorkoy</li>
<li><a href="http://jsbooks.revolunet.com/">JSBooks</a> - Julien Bouquillon</li>
<li><a href="http://manning.com/vinegar/">Third Party JavaScript</a> - Ben Vinegar and Anton Kovalyov</li>
<li><a href="http://amzn.com/0321812182">Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript</a> - David Herman</li>
<li><a href="http://eloquentjavascript.net/">Eloquent JavaScript</a> - Marijn Haverbeke</li>
</ul>
<p><strong>Blogs</strong></p>
<ul>
<li><a href="http://dailyjs.com/">DailyJS</a></li>
<li><a href="http://javascriptweekly.com/">JavaScript Weekly</a></li>
<li><a href="http://javascriptweblog.wordpress.com/">JavaScript, JavaScript&hellip;</a></li>
<li><a href="http://weblog.bocoup.com/">Bocoup Weblog</a></li>
<li><a href="http://www.adequatelygood.com/">Adequately Good</a></li>
<li><a href="http://www.nczonline.net/">NCZOnline</a></li>
<li><a href="http://perfectionkills.com/">Perfection Kills</a></li>
<li><a href="http://benalman.com/">Ben Alman</a></li>
<li><a href="http://dmitry.baranovskiy.com/">Dmitry Baranovskiy</a></li>
<li><a href="http://dustindiaz.com/">Dustin Diaz</a></li>
<li><a href="http://net.tutsplus.com/?s=javascript">nettuts</a></li>
</ul>
<p><strong>Podcasts</strong></p>
<ul>
<li><a href="http://devchat.tv/js-jabber/">JavaScript Jabber</a></li>
</ul>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p>
<h2 id="license"><a name="user-content-license" href="#license" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>License</h2>
<p>(The MIT License)</p>
<p>Copyright (c) 2014 Airbnb</p>
<p>Permission is hereby granted, free of charge, to any person obtaining<br />
a copy of this software and associated documentation files (the<br />
&lsquo;Software&rsquo;), to deal in the Software without restriction, including<br />
without limitation the rights to use, copy, modify, merge, publish,<br />
distribute, sublicense, and/or sell copies of the Software, and to<br />
permit persons to whom the Software is furnished to do so, subject to<br />
the following conditions:</p>
<p>The above copyright notice and this permission notice shall be<br />
included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED &lsquo;AS IS&rsquo;, WITHOUT WARRANTY OF ANY KIND,<br />
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br />
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY<br />
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br />
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br />
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<p><strong><a href="#table-of-contents">⬆ 返回目录</a></strong></p></article></body></html>